<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_data_tables.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:01 GMT -->

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>对账接入者管理系统</title>
    <meta name="keywords" content="对账接入者管理系统">
    <meta name="description" content="对账接入者管理系统">

    <link rel="shortcut icon" href="{{asset('dealer/img/favicon.ico')}}">
    <link href="{{asset('dealer/css/bootstrap.min.css')}}" rel="stylesheet">
    <link href="{{asset('dealer/css/font-awesome.min.css')}}" rel="stylesheet">

    <!-- Data Tables -->
    <link href="{{asset('dealer/css/plugins/dataTables/dataTables.bootstrap.css')}}" rel="stylesheet">

    <link href="{{asset('dealer/css/animate.min.css')}}" rel="stylesheet">
    <link href="{{asset('dealer/css/style.min.css')}}" rel="stylesheet">

    <link href="{{asset('dealer/css/plugins/datapicker/datepicker3.css')}}" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="{{asset('layui/src/css/layui.css')}}" />

    <link href="{{asset('layui-v2.3.0/layui/css/layui.css')}}" rel="stylesheet">
</head>

<body class="gray-bg">
<style>
    table.dataTable thead .sorting:after {
        content: "";
    }

    table.dataTable,
    .table-bordered {
        text-align: center;
    }


</style>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row" style="margin-bottom: 15px">
        <div class="col-sm-3">
            <div class="input-group">
                <input type="text" placeholder="昵称或联系方式" id="like" class="input-sm form-control" style="margin-left:0 ">
                <span class="input-group-btn">
                        <button type="button" class="btn btn-sm btn-primary" id="searchkey"> 搜索</button>
                    </span>
            </div>
        </div>
        <div class="col-sm-3 m-b-xs">
            <select id="rankselect" class="input-sm form-control input-s-sm inline" style="margin-left:0;width:58%;float:right">
                <option value="">请选择等级</option>
                <option value="5">普通用户</option>
                <option value="1">经销商</option>
                <option value="2">合伙人</option>
                <option value="3">服务中心</option>
            </select>
            <span style="float:right;height: 30px;line-height: 30px;">等级：</span>
        </div>
        <div class="col-sm-5 m-b-xs" style="width: 45%">
            <div class="form-group">
                <div class="input-daterange input-group" id="datepicker" style="margin-left: 10%;">
                    <span class="input-group-addon">时间段：</span>
                    <input type="text" class="input-sm form-control" id="datetime" placeholder="请选择日期" style="margin-left: 0" />
                    <span class="input-group-addon">到</span>
                    <input type="text" class="input-sm form-control" id="datetime1" placeholder="请选择日期" style="margin-left: 0" />
                    <button type="button" class="btn btn-sm btn-primary" style="position: absolute" id="searchClist"> 搜索</button>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>推荐用户管理</h5>
                </div>
                <div class="ibox-content">
                    <div class="row" style="margin-bottom: 5px">
                    </div>
                    <table class="table table-striped table-bordered table-hover dataTables-example">
                        <thead>
                        <tr>
                            <th style="text-align: center;">
                                <strong>序号</strong>
                            </th>
                            <th style="text-align: center;">
                                <strong>昵称</strong>
                            </th>
                            <th style="text-align: center;">
                                <strong>联系方式</strong>
                            </th>
                            <th style="text-align: center;">
                                <strong>等级</strong>
                            </th>
                            <th style="text-align: center;">
                                <strong>推荐时间</strong>
                            </th>
                        </tr>
                        </thead>
                        <tbody id="tbody-content">


                        </tbody>
                    </table>
                    <div class="row">
                        <div id="pages" style="float: right;"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="{{asset('dealer/js/jquery.min.js')}}"></script>
<script src="{{asset('dealer/js/bootstrap.min.js')}}"></script>
<script src="{{asset('dealer/js/plugins/jeditable/jquery.jeditable.js')}}"></script>
{{--<script src="{{asset('dealer/js/plugins/dataTables/jquery.dataTables.js')}}"></script>--}}
{{--<script src="{{asset('dealer/js/plugins/dataTables/dataTables.bootstrap.js')}}"></script>--}}
<script src="{{asset('dealer/js/content.min.js')}}"></script>


<script src="{{asset('dealer/js/plugins/datapicker/bootstrap-datepicker.js')}}"></script>
<script src="{{asset('dealer/js/plugins/cropper/cropper.min.js')}}"></script>

<script src="{{asset('laydate/laydate.js')}}"></script>

<script type="text/javascript" src="{{asset('lib/laypage/1.2/laypage.js')}}"></script>
<script type="text/javascript" src="{{asset('layui/src/layui.js')}}"></script>
<script src="{{asset('layui-v2.3.0/layui/layui.js')}}"></script>
<script>
    // $(document).ready(function () {
    //     $(".dataTables-example").dataTable();
    //     var oTable = $("#editable").dataTable();
    // });

    function fnClickAddRow() {
        $("#editable").dataTable().fnAddData(["Custom row", "New row", "New row", "New row", "New row"])
    };

    $(document).ready(function () {
        //两个日期范围选择
        layui.use(['laydate', 'jquery'], function () {
            var laydate = layui.laydate,
                $ = layui.jquery;
            var startIns = laydate.render({
                elem: '#datetime',
                max: 'new Date()',
                done: function (value, date, endDate) {
                    var min = $.extend({}, date),
                        max = $.extend({}, date);
                    min.month = min.month - 1;
                    max.month = max.month - 1;
                    //两个时间相差天数
                    var begintime = new Date().getTime();
                    var endtime = new Date(Date.parse(value)).getTime();
                    var nTime = begintime - endtime;
                    var day = Math.floor(nTime / 86400000);
                    max.date = max.date + day;

                    endIns.config.min = min;
                    endIns.config.max = max;
                    endIns.config.value = value;
                    $(endIns.config.elem).val(value);
                }
            });
            var endIns = laydate.render({
                elem: '#datetime1',
                min: 'value',
                done: function (value, date, endDate) {}
            });
        });

        var like=$('#like').val();
        var startDate=$('#datetime').val()
        var endDate=$('#datetime1').val()
        var rank =$('#rankselect option:selected') .val();//选中的值  //等级

        var sum = "";
        $.ajax({
            method: "POST",
            url: "C_list",
            data: {"rows": 10, "page": 1,'_token':'{{csrf_token()}}',"startDate":startDate,'endDate':endDate,'like':like,'rank':rank},
            async: false,
            dataType: "json",
            success:function (eval) {
                if ( eval.code == '200' ) {
                    sum = eval.data.total;
                    console.log('sum='+eval.data.total);
                } else if ( eval.code == '666' ) {
                    loginFaild();
                }
            }
        });

        layui.use('laypage', function(){
            var laypage = layui.laypage;

            //总页数大于页码总数
            laypage.render({
                elem: 'pages'
                ,count: sum //数据总数
                ,jump: function(obj){
                    console.log(obj.curr)
                    $.ajax({
                        method: "POST",
                        url: "C_list",
                        data: {"rows": 10, "page": obj.curr,'_token':'{{csrf_token()}}',"startDate":startDate,'endDate':endDate,'like':like,'rank':rank  },
                        dataType: "json",
                        success:function (eval) {
                            if ( eval.code == '200' ) {
                                $('#tbody-content').html("");
                                $.each(eval.data.records, function (index, item) {

                                    if(item.rank==0){
                                        item.rank='普通用户';
                                    }else if(item.rank==1){
                                        item.rank='经销商 ';
                                    }else if(item.rank==2){
                                        item.rank='合伙人 ';
                                    }else if(item.rank==3){
                                        item.rank='服务中心 ';
                                    }
                                    if(item.hasChild==true){//有下级
                                        var html = '<tr class="tr" data-id='+item.id+' data-orderid='+parseInt(index+1)+'  data-state="1" >\n' +
                                            // '                <td >' + parseInt(index+1) + '</td>' +

                                            '                <td >\n' +

                                            '                    <span style="margin-left: 10px;"  id="span'+item.id+'"  class="fa fa-angle-right" >'+parseInt(index+1)+'</span>\n' +
                                            '                </td>\n'+


                                            '                <td >' + item.name + '</td>' +
                                            '                <td >' + item.phone + ' </td>' +
                                            '                <td >' + item.rank + ' </td>' +
                                            '                <td >' + item.createDate + ' </td>' +
                                            '            </tr>';


                                    }else {//无下级
                                        var html = '<tr class="tr" data-id='+item.id+' data-orderid='+parseInt(index+1)+'  data-state="1" >\n' +
                                            // '                <td >' + parseInt(index+1) + '</td>' +

                                            '                <td >\n' +

                                            '                    <span  style="margin-left: 10px;" >'+parseInt(index+1)+'</span>\n' +
                                            '                </td>\n'+


                                            '                <td >' + item.name + '</td>' +
                                            '                <td >' + item.phone + ' </td>' +
                                            '                <td >' + item.rank + ' </td>' +
                                            '                <td >' + item.createDate + ' </td>' +
                                            '            </tr>';
                                    }

                                    $('#tbody-content').append(html);
                                });
                            }
                        }
                    });
                }
            });
        });

        //关键字搜索
        $('#searchkey').on('click', function () {

            var like=$('#like').val();

            var sum = "";
            $.ajax({
                method: "POST",
                url: "C_list",
                data: {"rows": 10, "page": 1,'_token':'{{csrf_token()}}' ,'like':like },
                async: false,
                dataType: "json",
                success:function (eval) {
                    if ( eval.code == '200' ) {
                        sum = eval.data.total;
                        console.log('sum='+eval.data.total);
                    } else if ( eval.code == '666' ) {
                        loginFaild();
                    }
                }
            });


            layui.use('laypage', function(){
                var laypage = layui.laypage;

                //总页数大于页码总数
                laypage.render({
                    elem: 'pages'
                    ,count: sum //数据总数
                    ,jump: function(obj){
                        console.log(obj.curr)
                        $.ajax({
                            method: "POST",
                            url: "C_list",
                            data: {"rows": 10, "page": obj.curr,'_token':'{{csrf_token()}}',"like":encodeURI(like) },
                            dataType: "json",
                            success:function (eval) {
                                if ( eval.code == '200' ) {
                                    $('#tbody-content').html("");
                                    $.each(eval.data.records, function (index, item) {

                                        if(item.rank==0){
                                            item.rank='普通用户';
                                        }else if(item.rank==1){
                                            item.rank='经销商 ';
                                        }else if(item.rank==2){
                                            item.rank='合伙人 ';
                                        }else if(item.rank==3){
                                            item.rank='服务中心 ';
                                        }
                                        if(item.hasChild==true){//有下级
                                            var html = '<tr class="tr" data-id='+item.id+' data-orderid='+parseInt(index+1)+'  data-state="1" >\n' +
                                                // '                <td >' + parseInt(index+1) + '</td>' +

                                                '                <td >\n' +

                                                '                    <span style="margin-left: 10px;"  id="span'+item.id+'"  class="fa fa-angle-right" >'+parseInt(index+1)+'</span>\n' +
                                                '                </td>\n'+


                                                '                <td >' + item.name + '</td>' +
                                                '                <td >' + item.phone + ' </td>' +
                                                '                <td >' + item.rank + ' </td>' +
                                                '                <td >' + item.createDate + ' </td>' +
                                                '            </tr>';


                                        }else {//无下级
                                            var html = '<tr class="tr" data-id='+item.id+' data-orderid='+parseInt(index+1)+'  data-state="1" >\n' +
                                                // '                <td >' + parseInt(index+1) + '</td>' +

                                                '                <td >\n' +

                                                '                    <span  style="margin-left: 10px;" >'+parseInt(index+1)+'</span>\n' +
                                                '                </td>\n'+


                                                '                <td >' + item.name + '</td>' +
                                                '                <td >' + item.phone + ' </td>' +
                                                '                <td >' + item.rank + ' </td>' +
                                                '                <td >' + item.createDate + ' </td>' +
                                                '            </tr>';
                                        }

                                        $('#tbody-content').append(html);
                                    });
                                }
                            }
                        });
                    }
                });
            });




        })

        //等级  时间  搜索
        $('#searchClist').on('click', function () {


            var startDate=$('#datetime').val()
            var endDate=$('#datetime1').val()
            var rank =$('#rankselect option:selected').val();//选中的值  //等级
            // alert($('#datetime').val().length)
            // alert($('#datetime1').val().length)
            // alert('rank='+rank.length)



            var sum = "";
            $.ajax({
                method: "POST",
                url: "C_list",
                data: {"rows": 10, "page": 1,'_token':'{{csrf_token()}}',"startDate":startDate,'endDate':endDate,'rank':rank},
                async: false,
                dataType: "json",
                success:function (eval) {
                    if ( eval.code == '200' ) {
                        sum = eval.data.total;
                        console.log('sum='+eval.data.total);
                    } else if ( eval.code == '666' ) {
                        loginFaild();
                    }
                }
            });



            if(rank.length==0){
                if($('#datetime').val().length!=10 || $('#datetime1').val().length!=10){

                    layui.use(['layer', 'form'], function(){
                        var layer = layui.layer;

                        layer.msg('请选择起止时间');
                    });
                    return false;
                }
            }

            layui.use('laypage', function(){
                var laypage = layui.laypage;

                //总页数大于页码总数
                laypage.render({
                    elem: 'pages'
                    ,count: sum //数据总数
                    ,jump: function(obj){
                        console.log(obj.curr)
                        $.ajax({
                            method: "POST",
                            url: "C_list",
                            data: {"rows": 10, "page": obj.curr,'_token':'{{csrf_token()}}',"startDate":startDate,"endDate":endDate,"rank":rank },
                            dataType: "json",
                            success:function (eval) {
                                if ( eval.code == '200' ) {
                                    $('#tbody-content').html("");
                                    $.each(eval.data.records, function (index, item) {

                                        if(item.rank==0){
                                            item.rank='普通用户';
                                        }else if(item.rank==1){
                                            item.rank='经销商 ';
                                        }else if(item.rank==2){
                                            item.rank='合伙人 ';
                                        }else if(item.rank==3){
                                            item.rank='服务中心 ';
                                        }
                                        if(item.hasChild==true){//有下级
                                            var html = '<tr class="tr" data-id='+item.id+' data-orderid='+parseInt(index+1)+'  data-state="1" >\n' +
                                                // '                <td >' + parseInt(index+1) + '</td>' +

                                                '                <td >\n' +

                                                '                    <span style="margin-left: 10px;"  id="span'+item.id+'"  class="fa fa-angle-right" >'+parseInt(index+1)+'</span>\n' +
                                                '                </td>\n'+


                                                '                <td >' + item.name + '</td>' +
                                                '                <td >' + item.phone + ' </td>' +
                                                '                <td >' + item.rank + ' </td>' +
                                                '                <td >' + item.createDate + ' </td>' +
                                                '            </tr>';


                                        }else {//无下级
                                            var html = '<tr class="tr" data-id='+item.id+' data-orderid='+parseInt(index+1)+'  data-state="1" >\n' +
                                                // '                <td >' + parseInt(index+1) + '</td>' +

                                                '                <td >\n' +

                                                '                    <span  style="margin-left: 10px;" >'+parseInt(index+1)+'</span>\n' +
                                                '                </td>\n'+


                                                '                <td >' + item.name + '</td>' +
                                                '                <td >' + item.phone + ' </td>' +
                                                '                <td >' + item.rank + ' </td>' +
                                                '                <td >' + item.createDate + ' </td>' +
                                                '            </tr>';
                                        }

                                        $('#tbody-content').append(html);
                                    });
                                }
                            }
                        });
                    }
                });
            });





        })



        //点击tr显示下级
        var dom='';
        var orderid='';//最顶级的自然序号
        var num=0;  //序号偏移量
        var level=0; //等级
        $('body').on('click' ,'.tr' , function(){
            dom=$(this);
            orderid=$(this).data('orderid');
            var id=$(this).attr('data-id');
            if($(this).hasClass('id'+id)){//收起下级
                $(this).removeClass('id'+id);

                $("#span"+id).addClass('fa-angle-right');
                $("#span"+id).removeClass('fa-angle-down');

                if($(this).attr('data-pid')){//如果点击的tr有pid ，即不是顶级
                    $('.tr[data-pid="'+id+'"]').remove();
                }else if(  isNaN( $(this).attr('data-pid'))  ){//如果点击的tr没有pid ，即是顶级
                    $('.dele'+orderid).remove();
                }

            }else{//展示下级
                $(this).addClass('id'+id);
                $.ajax({
                    method: "POST",
                    url: "C_list",
                    data: {"rows": 100, "page": 1,'_token':'{{csrf_token()}}',"pid": id },
                    dataType: "json",
                    success:function (eval) {
                        // console.log('eval.code.length='+eval.code.length)

                        if ( eval.code == '200' ) {
                            $("#span"+id).removeClass('fa fa-angle-right');
                            $("#span"+id).addClass('fa fa-angle-down');

                            num=num+10;

                            $.each(eval.data.records, function (index, item) {

                                if(item.rank==0){
                                    item.rank='普通用户';
                                }else if(item.rank==1){
                                    item.rank='经销商 ';
                                }else if(item.rank==2){
                                    item.rank='合伙人 ';
                                }else if(item.rank==3){
                                    item.rank='服务中心 ';
                                }

                                if(item.hasChild==true){//有下级
                                    var html = '<tr class="tr dele'+orderid+'"   data-pid='+id+'    data-id='+item.id+' data-orderid='+parseInt(orderid)+' >\n' +
                                        '                <td >\n' +
                                        '                    <span  style="margin-left: '+num+'px;" id="span'+item.id+'" class="fa fa-angle-right" >'+orderid+'</span>\n' +
                                        '                </td>\n'+
                                        '                <td >' + item.name + '</td>' +
                                        '                <td >' + item.phone + ' </td>' +
                                        '                <td >' + item.rank + ' </td>' +
                                        '                <td >' + item.createDate + ' </td>' +
                                        '            </tr>';

                                     }else{
                                        var html = '<tr class="tr dele'+orderid+'"   data-pid='+id+'    data-id='+item.id+' data-orderid='+parseInt(orderid)+' >\n' +
                                            // '

                                            '                <td >\n' +
                                            '                    <span  style="margin-left: '+num+'px;"   >'+orderid+'</span>\n' +
                                            '                </td>\n'+


                                            '                <td >' + item.name + '</td>' +
                                            '                <td >' + item.phone + ' </td>' +
                                            '                <td >' + item.rank + ' </td>' +
                                            '                <td >' + item.createDate + ' </td>' +
                                            '            </tr>';
                                    }







                                dom.after(html);

                            })

                        }
                    }
                });





            }

        })






    })


    function loginFaild() {

        alert('登录失效')
        var t = setInterval(function () {
            window.location.href="login";
            clearInterval(t);
        }, 2000);
    }

















</script>


</body>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_data_tables.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:02 GMT -->

</html>